<% breadcrumb :checkin_session, current_event, @session%>

<%= render 'stats' %>

<div class="row">
  <div class="col-lg-12">
    <div class="ibox float-e-margins">
      <div class="ibox-title">
        <h5>用户签到管理</h5>
      </div>
      <div class="ibox-content">

        <div class="row">
          <div class="col-xs-6">
            <h3>共找到 <strong class="text-success">
              <%= @attendees.total_count %></strong> 条记录
            </h3>
          </div>
          <div class="col-xs-6">
            <%= link_to '签到数据导出', event_session_company_checkin_export_path(current_event, @session), class: 'btn btn-white btn-sm pull-right' %>
          </div>
        </div>

        <div class="row m-b-md m-t-md">

          <div class="col-sm-4 m-b-xs">
            <div data-toggle="buttons" class="btn-group">
              <% { '已签到' => '1', '未签到' => '-1'}.each do |k, v| %>
                  <label class="btn btn-sm btn-white <%=params[:checked_in] == v ? 'active' : ''%>">
                    <input type="radio" name="checked_in" value="<%=v%>" <%=params[:checked_in] == v ? 'checked' : ''%>> <%=k%> </label>
              <% end %>
            </div>
          </div>

        </div>

        <div class="table-responsive">
          <% if params[:checked_in] == '1' %>
          <!--已签到-->
          <table class="table table-striped">
            <thead>
            <tr>
              <th>序号</th>
              <th>公司</th>
              <th>签到人</th>
              <th>手机号码</th>
              <th>签到时间</th>
              <th>管理</th>
            </tr>
            </thead>
            <tbody>
            <% @attendees.each_with_index do |attendee, index| %>
                <tr>
                  <td>
                    <%= index+1 %>
                  </td>
                  <td>
                    <span class="text-success"> <%=attendee.company%> </span>
                  </td>
                  <td title="编号：<%=attendee.attendee_number%>"><%=attendee.name%></td>
                  <td><%=attendee.mobile%></td>
                  <td><%=attendee.session_checked_in(@session.id) ? attendee.session_checked_in(@session.id).checked_in_at.to_s(:short) : ''%></td>
                  <td>
                    <%= link_to '取消签到', event_session_uncheck_in_path(current_event, @session, attendee), method: :delete, data: {confirm: '是否确认取消签到?'}, class: 'btn btn-xs btn-white' %>
                  </td>
                </tr>
            <% end %>
            </tbody>
          </table>
          <% else %>
          <table class="table table-striped">
            <thead>
            <tr>
              <th>序号</th>
              <th>公司</th>
            </tr>
            </thead>
            <tbody>
            <% @attendees.each_with_index do |attendee, index| %>
                <tr>
                  <td>
                    <%= index+1 %>
                  </td>
                  <td> <%=attendee.company%> </td>
                </tr>
            <% end %>
            </tbody>
          </table>
          <% end %>

        </div>

        <div class="row">
          <div class="col-sm-12">
            <%= paginate @attendees %>
          </div>
        </div>

      </div>
    </div>
  </div>
</div>